#!/usr/bin/env python3
"""
验证用户数据脚本
"""

import sqlite3

def check_users():
    """检查数据库中的用户"""
    try:
        conn = sqlite3.connect('evintro.db')
        cursor = conn.cursor()
        
        # 检查users表是否存在
        cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='users'")
        users_table_exists = cursor.fetchone()
        
        if users_table_exists:
            print("✅ users表存在")
            
            # 查询所有用户
            cursor.execute("SELECT username, role, is_active FROM users")
            users = cursor.fetchall()
            
            if users:
                print("✅ 已创建的用户:")
                for user in users:
                    print(f"  用户名: {user[0]}, 角色: {user[1]}, 激活状态: {user[2]}")
            else:
                print("❌ users表中没有数据")
        else:
            print("❌ users表不存在")
            
        conn.close()
        
    except Exception as e:
        print(f"❌ 检查用户数据时出错: {e}")

if __name__ == "__main__":
    check_users()